package com.wf.ew.sell.controller;

import com.wf.ew.common.BaseController;
import com.wf.ew.common.JsonResult;
import com.wf.ew.common.PageResult;
import com.wf.ew.sell.model.OutBill;
import com.wf.ew.sell.model.OutBillSon;
import com.wf.ew.sell.service.OutBillService;
import com.wf.ew.sell.service.OutBillSonService;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import net.sf.json.JSONArray;

/**
 *
 * controller
 * @author : Doman
 * @date : 2019-12-06 17:43:45
 * @version ：1.0
 */

@Controller
@RequestMapping("/sell/outBillSon")
public class OutBillSonController extends BaseController {

	@Autowired
	private OutBillSonService outBillSonService;
	@Autowired
	private OutBillService outBillService;
	
	/**
	 * 页面
	 **/
	@RequiresPermissions("outBillSon:view")
	@RequestMapping()
	public String outBillSon(Model model, OutBill outBill) {
		if(outBill!=null && !outBill.getId().equals("")){
			model.addAttribute("outBill",outBillService.getById(outBill));
		}
		return "sell/outBillSon.html";
	}

	/**
	 * 查询列表
	 */
	@RequiresPermissions("outBillSon:view")
	@RequestMapping(value = "/list", produces = {"text/html;charset=UTF-8;"})
	@ResponseBody
	public String list(PageResult<T> page, OutBillSon outBillSon){
		return outBillSonService.list(page, outBillSon,getLoginUser());
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("outBillSon:view")
	@RequestMapping(value = "/ajaxList", produces = {"text/html;charset=UTF-8;"})
	@ResponseBody
	public String ajaxList(OutBillSon outBillSon){
		return JSONArray.fromObject(outBillSonService.list(outBillSon,getLoginUser())).toString();
	}

	/**
	 * 新增
	 **/
	@RequiresPermissions("outBillSon:add")
	@ResponseBody
	@RequestMapping("/add")
	public JsonResult add(Model model, OutBillSon outBillSon) {
		return outBillSonService.add(outBillSon, getLoginUser());
	}

	/**
	 * 修改
	 **/
	@RequiresPermissions("outBillSon:update")
	@ResponseBody
	@RequestMapping("/update")
	public JsonResult update(Model model, OutBillSon outBillSon) {
		return outBillSonService.update(outBillSon, getLoginUser());
	}

	/**
	 * 批量删除
	 **/
	@RequiresPermissions("outBillSon:delete")
	@RequestMapping("/delete")
	@ResponseBody
	public JsonResult delete(OutBillSon outBillSon ) {
		return outBillSonService.delete(outBillSon, getLoginUser());
	}

}
